<?php
declare (strict_types = 1);

namespace app\model;

use think\Model;
use think\model\concern\SoftDelete;

/**
 * @mixin Model
 */
class Tags extends Model
{
    use SoftDelete;
    protected $table = 'think_tags';
    protected $pk = 'id';
    protected $autoWriteTimestamp = true;
    protected $createTime = 'create_time';//创建时间
    protected $updateTime = 'update_time';//更新时间
    protected string $deleteTime = 'delete_time';//删除时间

    /**
     * 标签状态 1：上架
     */
    public const STATE_ON_SHELF = 1;//正常

    /**
     * 标签状态 0：下架
     */
    public const STATE_OFF_SHELF = 0;//下架

    public function setStateAttr(string|int $value): int
    {
        return $value ? self::STATE_ON_SHELF : self::STATE_OFF_SHELF;
    }

    public function getStateAttr(int $value): bool
    {
        return $value === self::STATE_ON_SHELF;
    }
}
